Skip to content

Fix main.py to generate valid JSON from input files#407

Open
hongjunki-405 wants to merge 1 commit intoagwaBom:mainfrom
hongjunki-405:main
Open

Fix main.py to generate valid JSON from input files#407
hongjunki-405 wants to merge 1 commit intoagwaBom:mainfrom
hongjunki-405:main

Conversation

@hongjunki-405
Copy link
Copy Markdown

Changes:

  1. path_to_file_list (around line XX)
    Bug: opened the file with mode 'w' and returned undefined variable lines.
    Fix: open the file in read mode ('r'), read all lines, strip trailing '\n' and return the list.

  2. train_file_list_to_json (around line YY)
    Bug: wrong escaping logic and incorrect JSON template

    • file.replace('\\', '\\') did nothing.
    • condition if '/' or '"' in file: was always True.
    • English variable was overwritten by german file.
    • JSON string used wrong keys and wrong order.
      Fix: properly escape backslash, double quote and slash, then build a JSON line as
      -{"English":"...","German":"..."}.
  3. write_file_list (around line ZZ)
    Bug: opened the output file with mode 'r' and only wrote '\n' without content.
    Fix: open file in write mode ('w') and write each JSON string followed by a newline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant